package yaner.hotel.manager.resource.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yaner.hotel.manager.common.dto.roomType.RoomTypeAddDto;
import yaner.hotel.manager.common.dto.roomType.RoomTypeDto;
import yaner.hotel.manager.common.dto.roomType.RoomTypeUpdateDto;
import yaner.hotel.manager.common.vo.ResponseVo;
import yaner.hotel.manager.common.vo.SelectOptionVo;
import yaner.hotel.manager.common.vo.RoomTypeVo;
import yaner.hotel.manager.resource.service.IRoomTypeService;

import java.util.List;

/**
 * @Author kf-leig
 * @Description: 房型管理
 * @Version 1.0
 * @Date 2024年05月22日11:31:00
 */
@RestController
public class RoomTypeController {
    @Autowired
    private IRoomTypeService roomTypeService;

    @PostMapping("/room-type-list")
    public ResponseVo<List<RoomTypeVo>> roomTypeList(@RequestBody RoomTypeDto roomTypeDto) {
        List<RoomTypeVo> roomTypeVoList = roomTypeService.roomTypeList(roomTypeDto);
        return ResponseVo.success(roomTypeVoList);
    }

    @GetMapping("/room-type-code-list")
    public ResponseVo<List<SelectOptionVo>> roomTypeCodeList(boolean repeatFlag) {
        List<SelectOptionVo> roomTypeCodeVoList = roomTypeService.roomTypeCodeList(repeatFlag);
        return ResponseVo.success(roomTypeCodeVoList);
    }

    @GetMapping("get-room-type-info")
    public ResponseVo<RoomTypeVo> getRoomTypeInfo(@RequestParam("roomTypeId") String roomTypeId) {
        RoomTypeVo roomTypeVo = roomTypeService.getRoomTypeInfo(roomTypeId);
        return ResponseVo.success(roomTypeVo);
    }

    @PostMapping("add-room-type-info")
    public ResponseVo<String> addRoomTypeInfo(@RequestBody RoomTypeAddDto roomTypeAddDto) {
        String roomTypeId = roomTypeService.addRoomTypeInfo(roomTypeAddDto);
        return ResponseVo.success(roomTypeId);
    }

    @PostMapping("update-room-type-info")
    public ResponseVo<String> updateRoomTypeInfo(@RequestBody RoomTypeUpdateDto roomTypeUpdateDto) {
        String roomTypeId = roomTypeService.updateRoomTypeInfo(roomTypeUpdateDto);
        return ResponseVo.success(roomTypeId);
    }

    @DeleteMapping("delete-room-type-info")
    public ResponseVo<String> deleteRoomTypeInfo(@RequestParam("roomTypeId") String roomTypeId) {
        String roomTypeId1 = roomTypeService.deleteRoomTypeInfo(roomTypeId);
        return ResponseVo.success(roomTypeId1);
    }

}
